import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/pages/main/Main'
import Home from '@/pages/main/Home'
import noFound from '@/pages/main/404'
import Login from '@/pages/login/Login'
import Admin from '@/pages/admin/List'
import HouseAdd from '@/pages/house/Add'
import HouseList from '@/pages/house/List'
import HouseDetail from '@/pages/house/Detail'
import Person from '@/pages/person/Person'
import PersonDetail from '@/pages/person/Detail'
import PersonAdd from '@/pages/person/Add'
import Query from '@/pages/query/Query'
import Community from '@/pages/community/List'
import MoveInList from '@/pages/movein/List'
import MoveOutList from '@/pages/moveout/List'
import Suggest from '@/pages/suggest/Suggest'
import SuggestAdd from '@/pages/suggest/SuggestAdd'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: Main,
      children: [{
        path: '',
        component: Home,
        meta: {
          role: ['admin', 'person']
        }
      }]
    },
    {
      path: '/addHousehold',
      component: Main,
      children: [{
        path: '',
        component: HouseAdd,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/community',
      component: Main,
      children: [{
        path: '',
        component: Community,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/person',
      component: Main,
      children: [{
        path: '',
        component: Person,
        meta: {
          role: ['admin']
        }
      }, {
        path: '/person/detail/:userId',
        component: PersonDetail,
        meta: {
          role: ['admin']
        }
      }, {
        path: '/person/add/:houseId',
        component: PersonAdd,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/move', //迁入迁出
      component: Main,
      children: [{
        path: 'in',
        component: MoveInList, //模特列表
        meta: {
          role: ['admin']
        }
      }, {
        path: 'out',
        component: MoveOutList, //模特列表
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/household',
      component: Main,
      children: [{
        path: '',
        component: HouseList,
        meta: {
          role: ['admin']
        }
      }, {
        path: '/household/detail/:houseId',
        component: HouseDetail,
        meta: {
          role: ['admin']
        }
      }, {
        path: '/household/add',
        component: HouseAdd,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/query',
      component: Main,
      children: [{
        path: '',
        component: Query,
        meta: {
          role: ['person']
        }
      }]
    },
    {
      path: '/suggest',
      component: Main,
      children: [{
        path: '',
        component: Suggest,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/suggestAdd',
      component: Main,
      children: [{
        path: '',
        component: SuggestAdd,
        meta: {
          role: ['person']
        }
      }]
    },
    {
      path: '/admin',
      component: Main,
      children: [{
        path: '',
        component: Admin,
        meta: {
          role: ['admin']
        }
      }]
    },
    {
      path: '/login',
      component: Login,
      meta: {
        role: ['admin', 'person']
      }
    },
    {
      path: '/404',
      component: noFound,
      meta: {
        role: ['admin', 'person']
      }
    },
    {
      path: '*',
      redirect: '/404',
      meta: {
        role: ['admin', 'person']
      }
    }
  ]
})
